#!/usr/bin/python
# -*- coding: UTF-8 -*-

import paramiko

private_key = paramiko.RSAKey.from_private_key_file('/root/.ssh/y')

transport = paramiko.Transport(('192.168.191.149', 22))
transport.connect(username='root', pkey=private_key )

sftp = paramiko.SFTPClient.from_transport(transport)


# 将本地文件上传至服务器 
localpath='/root/1/1put.txt'
remotepath='/root/2/1put.txt'
sftp.put(localpath,remotepath)


# 将服务器文件下载到本地
remotepath='/root/2/2get.txt'
localpath='/root/1/2get.txt'
sftp.get(remotepath, localpath)

transport.close()
